import { packApiUrl } from "@/utils/common.js"

export async function request(config={}){	
	let {
		url,
		data={},
		method="GET",
		header={}
	} = config
	url =packApiUrl(url);
	return new Promise((resolve,reject)=>{	
		uni.request({
			url,
			data,
			method,
			header,
			success:res=>{
				resolve(res.data || res)
			},
			fail:err=>{
				uni.showToast({
					title: '网络错误',
					icon: 'none'
				})
				reject(err)
			}
		})
	})
}
